{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "01538419",
   "metadata": {},
   "source": [
    "--------\n",
    "* 2022-10-18\n",
    "* python学习第九周\n",
    "* 记录人：拆拆"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "32d2e3d4",
   "metadata": {},
   "source": [
    "# 本周知识点"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ba4752b5",
   "metadata": {},
   "source": [
    "> 1. while循环\n",
    "> 2. 购物车的练习\n",
    "> 3. 元组_集合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "1e89e1e2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "喜欢吴世勋 0\n",
      "喜欢吴世勋 1\n",
      "喜欢吴世勋 2\n",
      "喜欢吴世勋 3\n",
      "喜欢吴世勋 4\n"
     ]
    }
   ],
   "source": [
    "# while True 可以实现 for + range 的方法\n",
    "# while True 一般用于不确定的循环次数或者无限次循环操作。\n",
    "count = 0\n",
    "while True:\n",
    "    print(\"喜欢吴世勋\",count)\n",
    "    count +=1\n",
    "    if count == 5:\n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "f0d9cf8e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import getpass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "1ab0dea0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hide_card:········\n"
     ]
    }
   ],
   "source": [
    "hide_card = int(getpass.getpass(\"hide_card:\"))\n",
    "count = 0\n",
    "print:(\"hide_card\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "e65bc9bd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hide_card:60\n"
     ]
    }
   ],
   "source": [
    "# 猜数字小游戏： 0<n<100 ,5次机会猜数字，每次猜完出题人提示你猜的有点大（有点小）\n",
    "\n",
    "\n",
    "hide_card = int(input(\"hide_card:\")) #出题人\n",
    "count = 0\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2c207d9f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "游戏开始了\n",
      "guess_digit59\n",
      "往大了猜.\n"
     ]
    }
   ],
   "source": [
    "if hide_card <100 and hide_card>0 :\n",
    "    print(\"游戏开始了\")\n",
    "    while True:\n",
    "        if count <5:\n",
    "            guess_digit = int(input(\"guess_digit\"))# 玩游戏的人\n",
    "            if guess_digit == hide_card:\n",
    "                print(\"yes,you got it.\")\n",
    "                break\n",
    "            elif guess_digit > hide_card:\n",
    "                print(\"往小了想想...\")\n",
    "            else:\n",
    "                print(\"往大了猜.\")\n",
    "            count = count+1\n",
    "        else:\n",
    "            print(\"猜这么多次都不对，你个笨蛋！\")\n",
    "            print(\"正确答案是： %s\"%hide_card)\n",
    "            break\n",
    "else:\n",
    "    print(\"请输入数字再0-99之间。不要耍赖！\")\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a2e1d7ec",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
